package edu.ynu.hhy.architectureclass.service;

import edu.ynu.hhy.architectureclass.common.service.LogicService;
import edu.ynu.hhy.architectureclass.dao.UserDao;
import edu.ynu.hhy.architectureclass.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

@Service
public class UserService extends LogicService<UserDao, User, Long> {

    public UserService(@Autowired UserDao dao) {
        super(dao);
    }

    public String login(String username, String password) {
        User user = findByUsername(username);
        if (user != null && user.getPassword().equals(password)) {
            return "登录成功";
        } else {
            return "用户名或密码错误";
        }
    }

    public User findByUsername(String username) {
        return dao.findByUsername(username);
    }
}
